package set.test;

import set.Car;

import java.util.TreeSet;

public class TreeSetDemo2 {
    public static void main(String[] args) {
        TreeSet<Car> cars = new TreeSet<>();
        //创建对象
        Car c1 = new Car("kkk",99);
        Car c2 = new Car("tt",100);
        Car c3 = new Car("yy",10);
        //添加到集合
        cars.add(c1);
        cars.add(c2);
        cars.add(c3);
        //这里是重写了比较方法通过价格进行比较输出
        System.out.println(cars);
    }
}
